package com.pengxun.mall.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.szeastroc.common.result.Result;
import com.szeastroc.common.result.ResultUtils;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;



import  com.pengxun.mall.dto.StoreDTO;
import  com.pengxun.mall.dto.StoreSearchDTO;
import  com.pengxun.mall.vo.StoreVO;
import  com.pengxun.mall.service.StoreService;
import com.szeastroc.common.jdbc.page.Page;

@RestController
@RequestMapping("/store")
public class  StoreController{

   @Resource
   private StoreService storeService;
   
   @RequestMapping("/insert")
   public Result<Object> insert(@RequestBody StoreDTO storeDTO){
       storeService.insert(storeDTO);    
	   return ResultUtils.render();
   }
   
   @RequestMapping("/update")
   public Result<Object> update(@RequestBody StoreDTO storeDTO){
      storeService.update(storeDTO);
	   return ResultUtils.render();
   }
   
   @RequestMapping("/delete")
   public Result<Object> delete(Integer id){
       storeService.delete(id);
	   return ResultUtils.render();
   }
   
   @RequestMapping("/findById")
   public Result<Object> findById(Integer id) {
		return ResultUtils.render(storeService.findById(id));
	}
	
   @RequestMapping("/findAll")
   public Result<Object> findAll() {
		List<StoreVO> storeVOs = storeService.findAll();
		return ResultUtils.render(storeVOs);
	}
	
   @RequestMapping("/findByPage")
   public Result<Object> findByPage(@RequestBody StoreSearchDTO storeSearchDTO) {
	    Page page =  storeService.findByPage(storeSearchDTO);
		return ResultUtils.render(page);
	}
}
